#!/usr/bin/perl
#progress.cgi
require '/sbin/webmin/sysinfos/sysinfos-lib.pl';
require './remotesync-lib.pl';
sleep(5);
if(-e "/root/rsyncerr") {
	open(FG, "/root/rsyncerr");
	@ab=<FG>;
	close(FG);
	$errcode = $ab[0];
	$errcode =~ s/\r|\n//g;
	if($errcode eq 10){
		$err_msg=$text{'errconn'};
	}
	if($errcode eq 12){
		$err_msg=$text{'errnomod'};
	}
        `rm -f /root/rsyncerr`;
        &error_setup("ERROR");
        &error($err_msg);
}
else{  #***
my @ps = `ps ax|grep rsync`;
my $mark;
foreach $p (@ps){
	if($p =~ /-va/){
		$mark = 1;
		last;
	}
	else{
		$mark = 0;
		unlink("/var/nas/lock/rsync");
	}
}	

if($mark){

	&header($text{'mirror_title'},"","","","",undef,undef,"<meta http-equiv=refresh content=3>");
    	print $text{'jobrunning'};
    	&footer("index.cgi", $text{'index'});
}else{
    &redirect("index.cgi");
}
}  #***

